<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'base.categories.class.php');

class ProductCategoryBase extends BaseCategoriesBase {
	
	//constructor
	function ProductCategoryBase() {
		parent::BaseCategoriesBase();
		
		$this->table = 'pp_products_categories';
	}
	
	//methods
	function onAddImages($data_array, $target_id) {
		if( !is_array($data_array) ) {
			return false;	
		}
		$items_ids = array();
		if( is_array($data_array['categories_images']) ) {
			include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'module/product/product.image.class.php');
			$mObj = new ProductImageBase();
			
			foreach($data_array['categories_images'] as $k => $v) {
				if( strlen($v) > 0 ) {
					$d = array();
					$d['field_type'] = '2';
					$d['field_target'] = $target_id;
					$d['field_value'] = $v;
					$d['field_width'] = $data_array['categories_images_width'][$k];
					$d['field_height'] = $data_array['categories_images_height'][$k];
					$d['field_name'] = $data_array['categories_images_filename'][$k];
					$d['field_filename'] = $data_array['categories_images_filename'][$k];
					$items_ids[] = $mObj->addItem($d);
				}
			}
		}
		
		return $items_ids;
	}
}
//
?>